﻿app.factory('ArtistFactory', ['$http', '$q', function ($http, $q) {
    var o = {};
    o.artists = [];
    o.getArtistById = function (id) {
        for (var i = 0; i < o.artists.length; i++) {
            if (o.artists[i].ArtistId == id)
            {
                return o.artists[i];
            }
        }
    };
    var getAllArtists = function () {
        var config = { contentType: 'application/json' };
        $http.get('/api/apiArtist', config).success(function (data) {
            o.artists.length = 0;
            for (var i = 0; i < data.length; i++) {
                o.artists[i] = data[i];
            }
        });
    };

    getAllArtists();
    return o;
}]);